<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>html5</title>
</head>
<body>


    <script>
        {
            // 原型继承 原型继承父亲的实例

            function Fn (name,age) {
                this.name = name;
                this.age = age;
            }

            Fn.prototype = {
                func1: function () {
                    console.log('func1');
                },
                func2: function () {
                    console.log('func2');
                }
            };

            function Bn () {
                this.func = function () {
                    console.log('bn - func');
                }
            }

            Bn.prototype = new Fn('ws',27);

            let b = new Bn;

            console.log(b.func1());
            console.log(b.func2());
            console.log(b.name);
            console.log(b.age);

        }


        {   
            // call继承 继承父亲的私有属性方法

            function Fn () {
                this.x = 100;
            }

            Fn.prototype = {
                y: 200
            };

            function Bn () {
                Fn.call(this);
            }

            let b = new Bn;

            console.log(b);
            console.log(b.x);
            console.log(b.y);

        }
    

        {
            // 混合继承 就是 原型继承和call继承

        }

        {
            // 寄生组合继承 解决重复继承的问题

            // call 继承


            // Bn.prototype = Object.create(Fn.ptototype)

        }

        {
            // 中间对象继承法
            function Zn () {
                this.x = 2020;
            }

            Zn.prototype = {
                v: 3030
            };

            function Bn () {
                let temp = new Zn;
                for (const key in temp) {
                    this[key] = temp[key];
                }
                temp = null;
            }

            let b = new Bn;

            console.log('b',b);
        }

        {
            // 


        }


        {   
            // 原型链继承

            function Fn () {
                this.v = 3000
            }

            Fn.prototype = {
                w: 3030
            };

            function Bn () {
                this.x = 1010;
            }

            let b = new Bn;

            b.__proto__ = Fn.prototype;

            console.log(b.w);

        }

        {

            class Student {
                constructor (name,age) {
                    this.name = name;
                    this.age = age;
                }

                getInfo () {
                    console.log('information');
                }
            };

            class Boy extends Student {
                constructor (name,age,gender) {
                    super(name,age);
                    this.gender = 'boy'
                }
            } 

            let boy = new Boy('Crystal',28,'boy');

            console.log('boy',boy);
            
            boy.getInfo();

        }

        {
            
        }
    
    </script>
    
</body>
</html>